
// use lodash template to init some javascript and html files,set some environmental variables
var _ = require('lodash');
var Path = require('path');
var Fs = require('fs');
var Hosts = require('./hosts');
/**
 *
 * @param fileRelativePath the path relative of this dir
 * @param value
 */
function preset(fileRelativePath, value) {
    var file = Path.resolve(__dirname, fileRelativePath);
    var tmpl = _.template(Fs.readFileSync(file));
    var afterSet = tmpl(value);
    Fs.writeFileSync(file, afterSet);
    console.log('inited ' + file);
}

function init() {
    preset('../public/javascripts/main.js', {hostName: Hosts.getLocal().name});
}

module.exports = {
    init: init
};
